#!/usr/bin/env node;

// const EventEmitter = require('events').EventEmitter;
// const {EventEmitter} = require('events');

const Event = require('./05-event.js')

class Dog extends Event{
  constructor(name,age){
    super();
    this.#name=name;
    this.#energy=energy;
  }

  get name(){ return this.#name; }
  get energy(){ return this.#energy; }
  set energy(e){
    this.#energy = e;
    this.#startTimer();
  }

#startTimer(){
  if(this.#timer !== null) return;

  this.#timer=setInterval(()=>{
    if(this.energy>0){
      this.#energy--;
      this.emit('bark');
    }else{
      clearInterval(this.#timer);
      this.#timer=null;
    }
  }.1000);
}
  #name = '';
  #energy = 0;
  #timer = null;
}
"Hello World"

module.exports = Dog;
